import reqeust from '@/utils/request'
import { getToken } from '@/utils/token'

// 获取所有频道
export const getChannelListAPI = () => reqeust({
  url: '/v1_0/channels'
})

// 登录接口
export const loginAPI = ({ mobile, code }) =>
  reqeust({
    url: '/v1_0/authorizations',
    method: 'POST',
    data: {
      mobile,
      code
    }
  })

// 获取用户频道
export const getUserChannelListAPI = () =>
  reqeust({
    url: '/v1_0/user/channels',
    headers: {
      Authorization: `Bearer ${getToken()}`
    }
  })

// 获取文章列表
export const getArticlelListAPI = (channel_id) =>
  reqeust({
    url: '/v1_0/articles',
    method: 'GET',
    headers: {
      Authorization: `Bearer ${getToken()}`
    },
    params: {
      channel_id: channel_id,
      timestamp: new Date()
    }
  })
